var myPlayer = videojs("example_video_1");

//用于获取课程id
var courseId = window.location.search.split("=")[1] || 10 ;

var userId = localStorage.getItem("userId");

//点击按钮返回个人课程的主页;
$(".returnP").click(function(){
	window.location.href = "myTrain.html?userId=" + userId;
})
//获取课程信息
$.ajax({
	type:"POST",
	url:ptms.url.common.courseManger.courseItem,
	data:{
		id:courseId
	},
	success:function(data){
		var html = "";
		html += '<p class="contentTitle">' + data.coursesChnName + '</p>' + 
					'<p class="contentMenu">课程目录</p>' + 
					'<div class=" classList classCon">' + 
					'</div>'
		$(".contentBox").html(html);
		//获取专题信息
		$.ajax({
			type:"GET",
			url:ptms.url.common.courseManger.courseItemSubjectList,
			data:{
				coursesId:courseId
			},
			success:function(data){
				console.log(data);
				//用于为框架中加载具体的专题列表
				var newHtml = "";
				$.each(data, function(i,o) {
					
					newHtml += '<div class="classItem ">' + 
								'<div class="firstClassMenu" data-src="' + o.resourse[0].url + '">' + 
									'<p class="firstSpan" style="text-align:center">' + (i+1) + '</p>' + 
									'<p class="secondSpan">' + 
										'<img src="../images/_03.png" />' + o.spcSubName + '</p>' + 
									'<p class="thirdSpan">已开课</p>' + 
								'</div>' + 
							'</div>'
				});
				$(".classList").html(newHtml);
				
				//鼠标点击课程按钮是展示出课程章节的内容
				$("#trainClass .contentBox .classList .classItem .firstClassMenu").click(function(){
				//用于隐藏章节目录的
				//	$(this).siblings(".specialClassContent").slideToggle("hide");
					var src = $(this).data("src");
					
					var newSrc = $(".myV").attr("src");
					if(src != newSrc){
						$(".myV").attr("src",src);
						myPlayer.load();
						myPlayer.play();
					}
				})
			}
		})
	}
})













//视频列表的播放功能
//$("").click(function(){
//	var src = $(this).parent().siblings("p").data("src");
//	var src1 = $("#aa").attr("src");
//	console.log(src,src1)
//	if(src == src1){
//	}else{
//		$("#aa").attr("src",src);
//		myPlayer.load();
//	}
//	var time = $(this).children("span").html();
//	myPlayer.currentTime(time);
//	myPlayer.play();
//})
